/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import com.opensymphony.xwork2.ActionContext;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.Map;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import myconfession.utils.ConstantProvider;
import myconfession.utils.XMLUtility;

/**
 *
 * @author Liem
 */

public class PrintFbInfoAction {

    private String xml;
    private ByteArrayInputStream inputStream;

    public PrintFbInfoAction() {
    }

    public String execute() throws Exception {
        Map session = ActionContext.getContext().getSession();
        xml = (String) session.get("FB");
        StringReader sr = new StringReader(xml);
        String xslPath = ConstantProvider.getInstance().getRootPath() + "WEB-INF/xsl/printFbInfoPDF.xsl";
        inputStream = XMLUtility.generatePDF(xslPath, new StreamSource(sr));
        return "success";
    }

    public ByteArrayInputStream getInputStream() {
        return inputStream;
    }

    public void setInputStream(ByteArrayInputStream inputStream) {
        this.inputStream = inputStream;
    }

    public String getXml() {
        return xml;
    }

    public void setXml(String xml) {
        this.xml = xml;
    }

    

}